from deploy.gui.application import Application
from deploy.model.log import setLoggingLevel
import datetime
import logging
import sys

# TODO: Try to always elevate to administrator on launch under windows vista?

if __name__ == '__main__':
    mutex = None

    try:
        exitCode = -1

        # Create the application
        app = Application(sys.argv)

        setLoggingLevel()
        logger = logging.getLogger(__name__)

        logger.info('\n\n%s\nStarting DeploymentTool with arguments: %s' % (datetime.datetime.now(), sys.argv))
#        logger.info('Current sys.path: %s' % sys.path)        
        app.showMainWindow()

        # Run the application
        exitCode = app.exec_()

    finally:
        logging.shutdown()

    sys.exit(exitCode)
